var winW = $(window).width();
if (winW <1190) {
    $("li").remove(".list_1");
}
if(winW <890){
    $("li").remove(".list_2");
}
//if(winW <600){
//    $("li").remove(".list_3");
//}
var oUl = document.getElementById('ul1');
var aLi = oUl.getElementsByTagName('li');
var iLen = aLi.length;
var b = true;
//初始化数据处理
var c = '';
getList(1, 10);

function getList(num, num1) {
    invokeApi("website/getArticle", {"page": num, "count": num1, "showtype": "1"}, "", function (ret) {
        //var ret = '[{"URL":"https://www.baidu.com/","pic":"http://pic.sc.chinaz.com/Files/pic/moban/201612/moban1778_s.jpg","TITLE":"3222","height":"280","width":"190"},{"URL":"https://www.baidu.com/","pic":"http://pic.sc.chinaz.com/Files/pic/moban/201404/chahua3269_s.jpg","TITLE":"3222","height":"225","width":"190"},{"URL":"https://www.baidu.com/","pic":"http://pic.sc.chinaz.com/Files/pic/moban/201412/moban208_s.jpg","TITLE":"3222","height":"227","width":"190"},{"URL":"https://www.baidu.com/","pic":"http://pic.sc.chinaz.com/Files/pic/moban/201401/discuz2217_s.jpg","TITLE":"3222","height":"290","width":"190"},{"URL":"https://www.baidu.com/","pic":"http://pic2.sc.chinaz.com/Files/pic/moban/201312/chahua3133_s.jpg","TITLE":"3222","height":"280","width":"190"},]';
        var datas = eval(ret);
        var data = datas.DATAS;
        c = datas.ROWS_COUNT;
        if (!data.length) {
            //后续没有数据了
            return;
        }
        for (var i = 0; i < data.length; i++) {
            //获取高度最短的li
            var _index = getShort();
            var oDiv = document.createElement('div');
            var oImg = document.createElement('img');
            var oA = document.createElement('a');
            var section = document.createElement('section');
            oImg.src = data[i].pic;
            oA.href = data[i].THIRD_URL;
            $(oA).addClass("Analysis");
            $(oA).attr("analysis", i);
            $(oA).attr("target","_blank");
            //oImg.style.width = '225px';
            oImg.style.height = data[i].height * ( 250 / data[i].width ) + 'px';
            //alert(winW)
            if(winW <600){
                oImg.style.height = data[i].height * (310/(data[i].width ))/76.5 + 'rem';
            }

            section.appendChild(oImg);
            oDiv.appendChild(section);
            var oP = document.createElement('p');
            oP.innerHTML = data[i].TITLE;
            oDiv.appendChild(oP);
            oA.appendChild(oDiv);
            aLi[_index].appendChild(oA);
            $(".progress").fadeOut();
        }
        b = true;
    })
}
setTimeout(function () {
    var num=Math.ceil(c/10);
    for(var i=2;i<=num;i++){
        getList(i,10);
    }
}, 600);
function getShort() {
    var index = 0;
    var ih = aLi[index].offsetHeight;
    for (var i = 1; i < iLen; i++) {
        if (aLi[i].offsetHeight < ih) {
            index = i;
            ih = aLi[i].offsetHeight;
        }
    }
    return index;
}